<template>
  <div>
    <div class="topheader">
      <div class="img">
        <img :src="artist.picUrl" alt="">
      </div>
      <div class="button" @click="$router.go(-1)">
          <span class="iconfont icon-arrow-left-bold"></span>
          歌手
      </div>
      <!-- <div class="title">
         {{artist.briefDesc}}
      </div> -->
    </div>

    <div class="intro">
      <div class="intro-title">歌手简介</div>
      <div v-show="noun" class="packUp">
          <div class="intro-text">
            {{artist.briefDesc}}
          </div>
          <p @click="nounShow">
            展开
            <span class="iconfont icon-arrow-down-bold"></span>
          </p>
      </div>
      <div v-show="!noun" class="expansion">
            <div class="intro-text">
              {{artist.briefDesc}}
            </div>
          <p @click="nounShow">
            收起
            <span class="iconfont icon-arrow-up-bold"></span>
          </p>
      </div>
    </div>

    <div class="singerlist">
        <div class="title">热门单曲</div>
        <ul>
          <li>
            <div class="left-list iconfont icon-bo413"></div>
            <div class="right-list">
              <p class="song">播放全部<span>(共{{hotSongs.length}}首)</span></p>
            </div>
          </li>
          <li v-for="(item,index) in hotSongs" :key="index" @click="playmusic(item.id,item.name,item.ar)">
            <div class="left-list">{{index+1}}</div>
            <div class="right-list">
              <p class="song">{{item.name}}</p>
              <p class="singers">
                  <span v-for="(key,index) in item.ar" :key="index" >{{key.name}} &nbsp;&nbsp;</span>
              </p>
            </div>
          </li>
        </ul>
      </div>
  </div>
</template>

<script>
import {getDetail} from "../../api/singer";
export default {
    data() {
        return {
            hotSongs:{
                // tracks:[]
            },
            artist:"",
            noun: true
        }
    },
    methods:{
        nounShow(){
          this.noun = !this.noun;
        },
        getDetailFun(){
            let id = this.$route.query.id;
            if(!id){
                return ;
            }
            getDetail({id:id}).then(data=>{
                // console.log(data);
                this.artist = data.artist
                this.hotSongs = data.hotSongs;
            })
        },
        playmusic(id,name,ar){
          let playMusicData = {
            coverImgUrl:this.artist.img1v1Url,
            id,
            name,
            ar,
            tracks:this.hotSongs
          }
          // 数据存储
          this.$store.commit("musicDatafun",playMusicData )
        },
        
    },
    created(){
        this.getDetailFun();
    }
}
</script>


<style lang="less">
.intro{
  padding: 10px;
  background: #fff;
  .intro-title{
      line-height: 57px;
      font-size: 18px;
      color: #333;
      font-weight: 900;
  }
  .packUp{
    .intro-text{
      color: #666;
      font-size: 14px;
      text-indent: 2em;
      display: -webkit-box;
      -webkit-box-orient: vertical;
      -webkit-line-clamp: 3;
      overflow: hidden;
    }
    p{
      font-size: 14px;
      margin-top: 25px;
      text-align: center;
    }
  }
  .expansion{
    .intro-text{
      color: #666;
      font-size: 14px;
      text-indent: 2em;
    }
    p{
      font-size: 14px;
      margin-top: 25px;
      text-align: center;
    }
  }
}


body {
  background: #fff;
}
.topheader {
  position: relative;
  .img {
    height: 300px;
    // background: pink;
    img{
      width: 100%;
      height: 100%;
    }
  }
  .button {
    position: absolute;
    top: 12px;
    left: 12px;
    font-size: 16px;
    color: #fff;
  }
  .title{
    width: 300px;
    position: absolute;
    left:12px;
    right: 12px;
    bottom: 30px;
    font-size: 14px;
    font-weight: bold;
    color:#fff;
    height: 38px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.singerlist ul li:first-of-type {
    height: 35px;
    line-height: 35px;
    padding: 0px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
    background: #fff;
    span{
        font-size: 12px;
    }
    .iconfont{
        line-height: 35px;
        font-size: 20px;
    }
  }
  .singerlist{
    .title{
      line-height: 57px;
      font-size: 18px;
      color: #333;
      font-weight: 900;
      margin-left: 10px;
    }
    ul {
        // margin-top: -35px;
        position: relative;
        // top: -35px;
      li {
        height: 30px;
        // line-height: 52px;
        // margin-bottom: 4px;
        border-bottom: 2px solid #F7F7F7;
        background: #fff;
        color: #333;
        padding: 11px 0px;
        display: flex;
        .left-list {
          width: 44px;
          height: 32px;
          line-height: 32px;
          text-align: center;
          font-size: 14px;
        }
        .right-list {
          max-width: 300px;
          .song {
            font-size: 16px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
          }
          .singers {
            width: 180px;
            overflow: hidden;
            text-overflow: ellipsis;
            white-space: nowrap;
            font-size: 12px;
            line-height: 22px;

          }
        }
      }
    }
  }
</style>
